SELECT items.id, items.title,items.title_eng, items.state, items.hideprice, items.anons, items.price2rub AS price, images.path , 0 + IF(items.title LIKE "%красив%", 40, 0) + IF(items.anons LIKE "%красив%", 5, 0) + IF(items.keywords LIKE "%красив%", 20, 0) + IF(items.comment LIKE "%красив%", 1, 0) + IF(items.title LIKE "%связк%", 40, 0) + IF(items.anons LIKE "%связк%", 5, 0) + IF(items.keywords LIKE "%связк%", 20, 0) + IF(items.comment LIKE "%связк%", 1, 0) + IF(items.title LIKE "%ключ%", 40, 0) + IF(items.anons LIKE "%ключ%", 5, 0) + IF(items.keywords LIKE "%ключ%", 20, 0) + IF(items.comment LIKE "%ключ%", 1, 0) as relevance FROM `items` INNER JOIN `images` ON images.id_item=items.id WHERE ((false OR (items.title LIKE "%красив%" OR items.anons LIKE "%красив%" OR items.keywords LIKE "%красив%" OR items.comment LIKE "% красив %") OR (items.title LIKE "%связк%" OR items.anons LIKE "%связк%" OR items.keywords LIKE "%связк%" OR items.comment LIKE "% связк %") OR (items.title LIKE "%ключ%" OR items.anons LIKE "%ключ%" OR items.keywords LIKE "%ключ%" OR items.comment LIKE "% ключ %")) ) AND images.visible=0 AND items.visible=1 AND items.price1_ck=0 AND items.state IN (1,2,3,4,7,9) GROUP BY items.id ORDER BY items.price2rub DESC LIMIT 0,32